package com.hjj.controller;

import com.hjj.dto.ResultDTO;
import com.hjj.exception.MyLengthException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

// 全局异常处理能力
@RestControllerAdvice
public class MyLengthExceptionController {
    @ExceptionHandler(MyLengthException.class)
    public ResultDTO myLengthExceptionHandler(MyLengthException e){
        ResultDTO resultDTO = new ResultDTO();
        resultDTO.setResult(ResultDTO.ERROR);
        resultDTO.setError(e.getMessage());

        return resultDTO;
    }
}
